home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / applic / NCSA_Telnet / PC / msdos / contributions / IRC.Bot.Doc < prev    next >
Encoding:
Text File  |  1993-08-04  |  18.7 KB  |  415 lines

  1. ************************************************************************
  2.  
  3. That Great Ursine of IRC, BalooBear, presents...
  4.  
  5.  '||''|.             .   '||''|.                  
  6.   ||   ||    ...   .||.   ||   ||    ...     .... 
  7.   ||'''|.  .|  '|.  ||    ||    || .|  '|. .|   ''    Version
  8.   ||    || ||   ||  ||    ||    || ||   || ||           1.2
  9.  .||...|'   '|..|'  '|.' .||...|'   '|..|'  '|...'
  10.                                                   
  11. The official guide to writing IRC bots !!!!!
  12.  
  13. ***********************************************************************
  14.  
  15. Standard Disclaimer Legal Junk
  16. ------------------------------
  17.       BalooBear cannot he held responsible for anything that happens 
  18.       as a result of using this document... Use at your own risk!!!!
  19.  
  20. Requirements
  21. ------------
  22.   o UNIX or compatible OS
  23.   o IRCII client
  24.   o A little knowledge of how /on commands work
  25.   o Imagination
  26.  
  27. What is a bot?
  28. --------------
  29.      A 'bot' is simply a collection of commands (a script) that responds
  30. to certain key phrases and commands from its owner and other IRC
  31. participants.  Popular features that people include in their bots are
  32. auto-opping of themselves and friends, deop protection for them
  33. (when someone deops them, the bot reops them), responding to certain
  34. words people say with cute responses, and the like.  This manual will
  35. show you how to do all these things, and I hope it will spur you on
  36. to make bots that do even more.  This manual only covers the basics, but
  37. bots can do MUCH more.
  38.  
  39. Mechanics of a bot
  40. ------------------
  41.      A bot appears as a seperate person on IRC, even though it is
  42. really just a script.  Your bot will have the same system address
  43. as you, and will run as a background task in your account.  Bots
  44. can leave IRC when you do automatically and change channels with
  45. you.  They can even be made to stay on IRC after you logout,
  46. 24-hrs/day, if so desired.
  47.  
  48.      A bot is just a collection of mostly /on commands (with some
  49. others thrown in sometimes) that is stored in a simple ASCII text
  50. file.  This file can be loaded into IRCII in several ways.  Since
  51. I assume most of you want your bot to run in the background and cause
  52. a minimum amount of hassle to you, I will show you the method I use
  53. to run my bot.  This method has many advantages.  But first, lets
  54. get into some actual bot code!
  55.  
  56. Common commands in a bot file
  57. -----------------------------
  58.      The first thing you'll want to have in your bot file is a
  59. nickname for your bot.  Usually, bot nicknames end in "bot" or "serv"
  60. or "srv".  You should make your bot's nick end in one of these three
  61. ways so as to not make people think it's a person.  BalooBot, my bot,
  62. is a good example.  When people see that kind of ending, they know he's
  63. just a program.  To specify a nickname, put this in your bot file:
  64.  
  65.      /nick whatever
  66.  
  67.      Remember, just use any text editor to make your bot file, as it is
  68. only an ASCII text file.
  69.      Next you should set exec_protection to off, so that your bot can
  70. operate properly, turn the display off, and turn the beep off by doing
  71. this:
  72.  
  73.      /set exec_protection off
  74.      /set display off
  75.      /set beep off
  76.  
  77.      Simple, eh?  Now we get to the good part - actually writing
  78. the key phrases and responses!!!  Many things can be done with a
  79. bot, and here are a few:
  80.  
  81. /ON PUBLIC - RESPONDING TO KEY PHRASES
  82. --------------------------------------
  83.      By using /on public commands, your bot can be made to respond to
  84. "key phrases" that anyone on the channel says.  Wildcards, such as *,
  85. can be used, and case does not matter.  The first form of the command
  86. responds to a key phrase only when the bot is specifically spoken to:
  87.  
  88.      /on public "* baloobot* hello*" / ==== Hi there, $0! ====
  89.      /on public "* hello* baloobot*" / ==== Hi there, $0! ====
  90.  
  91.      This line will respond with "==== Hi there, Fred! ====" if
  92. someone named Fred says "baloobot hello" or "hello baloobot".  This
  93. type of public will ONLY respond when someone specifically addresses
  94. the bot by name.  Another kind of /on public is this kind:
  95.  
  96.      /on public "* spam*" / ==== SPAM, SPAM, SPAM, SPAMMITY SPAM! ====
  97.  
  98.      ...which will output the phrase whenever the word "spam" is heard
  99. from anyone at any time.  BE WARNED, however, that most people do not
  100. take kindly to this kind of /on public statement, and will usually
  101. kick your bot if he keeps it up.  By making the bot only respond when
  102. addressed, you can make sure that it doesn't get people annoyed.
  103.      See the listing of BalooBot after this document for more ideas.
  104.  
  105. /ON MSG - RESPONDING TO MESSAGES
  106. --------------------------------
  107.      /on msg commands allow your bot to respond to /msg messages that
  108. people send to it.  The format is similar to /on public :
  109.  
  110.      /on msg "* help*" /exec -msg $0 cat HelpFile.txt
  111.  
  112.      ...will, when someone types "/msg BalooBot help", msg back to
  113. that person the contents of the file HelpFile.txt in the current dir.
  114. Bascially, anything that can be done with /on publics can also be
  115. done with /on msgs, the two commands simply respond to different
  116. kinds of input.  BalooBot's listing at the end of this document
  117. includes several /on msg commands, mostly for owner control.
  118.  
  119. AUTO-OPS and AUTO-REOPS
  120. ------------------------
  121.      Auto-ops can be incorporated into your bot, which will make
  122. him op you or any of your friends automatically and instantly upon /join
  123. of the channel the bot is on (assuming he is opped).  Auto-reops
  124. automatically reop you or friends when someone tries to deop you/them.
  125. Here is an example from BalooBot:
  126.  
  127.      /on join BalooBear /mode $C +o BalooBear; ==== BALOOBEAR!! ====
  128.      /on mode "* * *-O BalooBear" /mode $C +o BalooBear
  129.  
  130.      The first line auto-ops BalooBear upon joining the channel
  131. the bot is on (notice how $C represents the channel name).  The second
  132. line reops BalooBear immediately if somebody deops him.  See the
  133. listing of BalooBot for more examples.  Also note how a semicolon (;)
  134. is used to separate multiple commands on the same line.
  135.  
  136. SECURE (LOGIN-ID) BASED AUTO-OP
  137. -------------------------------
  138.      The previous auto-op commands will auto-op anyone with the right
  139. nickname.  On small channels this is usually no problem, but on large,
  140. well-known channels (such as #hottub, which is BalooBot's home), this
  141. can become a problem, as delinquents can take someone else's nick, get
  142. auto-opped by the bot (who think's its that person of that nick), and
  143. mass-kick everyone off the channel :(.... A way to avoid this is by
  144. using secure auto-opping that is based on login-id rather than just
  145. nickname.  Here's how: put this line once in your botfile, near
  146. the top:
  147.  
  148.      /on join * /who $0
  149.  
  150.      ...then for each person you want to auto-op, put in one of
  151. these:
  152.  
  153.      /on who "* * * jlynch wilkes1.wilkes.edu *" /mode $C +o $1
  154.  
  155.      Make sure to leave out the @ in the system address.
  156. Incidentially, the above one is just an example, but it would be
  157. nice to add to your bot (after all, I wrote this helpfile :)
  158.  
  159. KICK PROTECTION (AUTO-REJOIN-ON-KICK)
  160. -------------------------------------
  161.      Add something like this to make your bot kick-proof:
  162.  
  163.      /on raw_irc "*KICK * * BalooBot*" /msg BalooBot rejoin
  164.      /on msg "BalooBot rejoin" /join #channel
  165.  
  166.      BTW, you can't just do a /on raw_irc kick /join, because all
  167. operations after the raw_irc are carried out JUST BEFORE you are
  168. kicked... so having the bot msg itself to rejoin is a neccessary,
  169. if kludgy, extra step.  But hey... it works! :)
  170.  
  171.      Of course, someone can always ban your bot, then kick him.
  172. To get around this, simply put your bot on a non-2.7 server, with
  173. the /serv command.  Non-2.7 servers ignore bans, and essentially
  174. make your bot ban-proof.  Along with the next section on kill-
  175. proofness, these things will make it so that NO ONE on IRC, and I
  176. do mean NO ONE, will be able to get your bot off a channel in
  177. any way (KICK doesn't work, ban doesn't either, not even KILL!).
  178. Except possibly by making the channel invite-only, but on most
  179. big public-channels like #hottub, invite-only is almost never used.
  180.  
  181. KILL-PROOFNESS
  182. --------------
  183.      One simple line will make your bot kill-proof (instant
  184. reconnect upon kill):
  185.  
  186.      /on disconnect * /serv servername
  187.  
  188.      ...where you substitute your server name (for example,
  189. fairhope.andrew.cmu.edu, a good non-2.7 server) for the word
  190. "servername".
  191.  
  192. OWNER COMMANDS
  193. --------------
  194.      These commands use /on public statements, but can only be
  195. activated by the owner of the bot, not by anyone else.  The key is
  196. to include the owner's name as part of the statement:
  197.  
  198.      /on public "BalooBear bbot boot*" /kick $C $3
  199.  
  200.      ...will kick the person after the word "boot" off the channel.
  201. Note that all BalooBear has to type is "bbot boot nick" to kick
  202. that person, the "BalooBear" part of the /on public is only used
  203. to make sure that the command is from BalooBear; someone else trying
  204. to use the "bbot boot" command will get no response.
  205.      BalooBot also includes /on msg owner commands, for when the
  206. owner is not on the same channel as the bot.
  207.  
  208. JOIN-ON-INVITE
  209. --------------
  210.      This command will make the bot join any channel its owner
  211. /invites it to (make sure to put your nick in place of "BalooBear")
  212.  
  213.      /on invite "BalooBear" /join $1
  214.  
  215. SWITCH SERVERS
  216. --------------
  217.     This is a special owner command that causes the bot to switch
  218. to whatever server you tell it to:
  219.  
  220.      /on public "BalooBear BBot serv*" /serv $3
  221.      /on msg "BalooBear serv *" /serv $2
  222.  
  223.      so when BalooBear types "bbot serv lyman.pppl.gov" or
  224. "/msg BalooBot serv lyman.pppl.gov", BalooBot will switch to the
  225. lyman server.
  226.  
  227. EXIT-WITH-OWNER
  228. ---------------
  229.      This command will cause your bot to exit the IRC system when
  230. you do, automatically.  Note that if you want a bot to be on all
  231. the time, do not use this command, you must kill the bot process
  232. from the shell to stop it.
  233.  
  234.      /on channel_signoff "* BalooBear" /exit
  235.  
  236. STARTING YOUR BOT
  237. -----------------
  238.      OK, so you've written your bot, and now you want to try him out.
  239. Here's how, assuming you have a C-shell-based UNIX system (commands
  240. may vary for other shells):
  241.  
  242.      1. From the shell prompt, simply type:
  243.  
  244.         irc -b -l botfile
  245.  
  246.      ...where you replace the full pathname of the IRCII client
  247. on your machine for the word 'irc', and the name of the ASCII text
  248. file containing your bot for the word 'botfile'.
  249.      This will run your bot in the background, put up some stuff
  250. on the screen you should ignore, and then, after you hit return a
  251. few times, return your shell prompt to you.  The bot is now running
  252. as a background process that will continue indefinitely until you
  253. kill it, even after you logout.
  254.  
  255.      2. Now just join IRC yourself, take the nickname that your
  256. bot recognizes as its master's... and have fun!
  257.  
  258.      3. If you ever want to kill the bot for any reason (to start
  259. up an improved version, for example), just do a "ps -x" from the
  260. shell prompt, note the PID number of the bot process, and from the
  261. shell type "kill -9 pidnumber", replacing the PID number for the
  262. word "pidnumber".
  263.  
  264. CONCLUDING NOTE
  265. ---------------
  266.      Keep in mind that MUCH more can be done with bots, so much more that
  267. we have literally only covered the proverbial "tip of the iceberg" here.
  268. So go ahead, and get your hands dirty...  If you have any questions,
  269. I'm on IRC under "BalooBear", you can talk to me or leave a msgserv
  270. for me, or E-mail me at jlynch@wilkes1.wilkes.edu
  271.                                              _
  272.                                             /\\_\_.-----.___  _.._
  273.                                               / _    _      \//   \
  274.   BalooBear                                  / /      \       y--  |
  275.   John Lynch                                 |  /\  /\        \ __/
  276.   jlynch@wilkes1.wilkes.edu       ___________| _*/__*/_        \_
  277.                                  /   \\      +----.    ____      \_
  278.   -------------------------      \    ||           \__/ / /        \
  279.                                   +---+/               / /        /\\
  280.   High Byte Software               \ \                / /       _/
  281.   91 Hillside Street                '-+----_______---- /      --  \
  282.   Wilkes-Barre, PA, USA                 \___________--'            \
  283.   18702                                       /                     \
  284.                                              /                       \
  285.  
  286.  
  287. ================= LISTING OF BALOOBOT AS OF 4/9/92 ====================
  288.  
  289.  
  290. /comment *** BalooBot V3.7, BalooBear's IRC bot ***
  291. /comment *** now running off Fizzy's account ***
  292. /comment *** jointly commanded/owned by Fizzy/BalooBear ***
  293.  
  294. /comment *** Now with system-id checks (for auto-opping) ***
  295. /comment *** Also with kick protection (auto-rejoin on kick) ***
  296. /comment *** And kill-protection (instant auto-reconnect on kill) ***
  297. /comment *** running off a 2.6 server for ban protection ***
  298.  
  299. /serv fairhope.andrew.cmu.edu
  300.  
  301. /nick BalooBot
  302. /set novice off
  303. /set display off
  304. /set exec_protection off
  305. /set beep off
  306. /join #hottub
  307. /say ==== Hi everyone! ====
  308. /on join * /who $0
  309.  
  310. /comment ******************** PUBLICS ****************************
  311.  
  312. /on mode "* * *+O BalooBot*" /msg $0 ==== Thanks tons, $0!! ====
  313. /on public "* hello* BalooBot" / ==== Hi there, $0!! ====
  314. /on public "* BalooBot* hi*" / ==== Hello, $0!!! ====
  315. /on public "* BalooBot* hello" / ==== Greetings, $0!! ====
  316. /on public "* hi* BalooBot*" / ==== What's up, $0 ?!! ====
  317. /on public "* baloobot* thank*" / ==== No problemo, $0 ====
  318. /on public "* thank* baloobot*" / ==== Anytime, $0 ====
  319. /on public "* thanx* baloobot*" / ==== Don't mention it, $0!!! ====
  320. /on public "* baloobot* thanx*" / ==== Glad to help, $0!!! ====
  321. /on public "* baloobot* spam*" / ==== SPAM, SPAM, SPAM, SPAM, SPAMMITY SPAM!! ====
  322. /on public "* baloobot* amiga*" / ==== Commodore Amiga - Best PC on Earth!! ====
  323. /on public "* baloobot* commodore*" / ==== Commodore : maker of the legendary AMIGA! ====
  324. /on public "* baloobot* parrot*" / ==== "That parrot is NOT dead.. he's resting!" ====
  325. /on public "* baloobot* grail*" / ==== "Grail?  We've already got one!" ====
  326. /on public "* baloobot* sir robin*" / ==== "He is brave Sir Robin, brave Sir Robin" ====
  327. /on public "* baloobot* larch*" / ==== "AND NOW... THE LARCH" ====
  328. /on public "* baloobot* camelot*" / ==== "It's only a model!" ====
  329. /on public "* baloobot* floyd*" / ==== PINK FLOYD RULES! ====
  330. /on public "* baloobot* how* is* life*" / ==== Life sucks, as usual, $0 ====
  331. /on public "* baloobot* eat* me*" / ==== $0: I'd rather not :P ====
  332. /on public "* baloobot* who* made* you*" / ==== BalooBear did, of course! ====
  333. /on public "* baloobot* who* created* you*" / ==== BalooBear made me! ====
  334. /on public "* baloobot* who* is* your* master*" / ==== My master is BalooBear!  I obey him faithfully! ====
  335. /on public "* baloobot* self*destruct*" / ==== BLAM!!!!!!! ====
  336. /on public "* baloobot* who* is* BalooBear*" / ==== BalooBear is the bear from the Disney ====; ==== film, "The Jungle Book".  And he is my master! ====
  337. /on public "* baloobot* me* beer*" / ==== Throws a cold brewski to $0 ====
  338. /on public "* baloobot* where* you* live*" / ==== I live on IRC, silly! :) ====
  339. /on public "* baloobot* die*" / ==== DIE??? I AM IMMORTAL!!!! :) ====
  340. /on public "* baloobot* sex*" / ==== *blushes* Sorry, bots can't have sex, $0 ====
  341. /on public "* baloobot* suck*" / ==== $0, vulgarity is a crutch for the inarticulate ====
  342. /on public "* baloobot* go* hell*" / ==== No, I think YOU should go to hell, $0!!! :) ====
  343. /on public "* baloobot* fuck*" / ==== Watch the language, $0!!! :) ====
  344. /on public "* baloobot* shit*" / ==== Watch the language, $0, or I'll ====; ==== get the FCC after you! :) ====
  345. /on public "* baloobot* shut*up*" / ==== I'll shut up if you don't egg me on!! ====
  346.  
  347. /comment ******************** HELP! *********************************
  348.  
  349. /on public "* baloobot* help*" /msg $0 ==== HELP??  Call 911 !! ====
  350. /on public "* bbot* help*" /msg $0 ==== HELP??  Call 911 !! ====
  351. /on msg "* help*" /msg $0 ==== HELP??  Call 911 !! ====
  352.  
  353. /comment ******************* KICK / KILL PROTECTION ********************
  354.  
  355. /on raw_irc "*KICK * * BalooBot*" /msg BalooBot rejoin
  356. /on msg "BalooBot rejoin" /join #hottub
  357.  
  358. /on disconnect * /serv fairhope.andrew.cmu.edu
  359.  
  360. /comment ******************** AUTO RE-OPS *************************
  361. /comment *** inactive until I can figure out how to secure them ***
  362. /comment *** from jerks who take other ppl's nicks to get opped ***
  363.  
  364. /comment /on mode "* * *-O BalooBear*" / ==== NEVER DEOP MY MASTER, $0!!! ====;/mode $C +o BalooBear
  365. /comment /on mode "* * *-O Fizzy*" / ==== LEAVE MY CO-OWNER ALONE, $0!!! ====;/mode $C +o Fizzy
  366. /comment /on mode "* * *-O RontuWolf*" / ==== NEVER DEOP MY MASTER, $0!!! ====;/mode $C +o BalooBear
  367. /comment /on mode "* * *-O Dankari*" /mode $C +o Dankari
  368. /comment /on mode "* * *-O Zorg*" / ==== HEY!! LEAVE ZORG ALONE!! *reops Zorg* ====;/mode $C +o Zorg
  369. /comment /on mode "* * *-O Christina*" / ==== LEAVE HER ALONE!!! *reops Christina* ====;/mode $C +o Christina
  370. /comment /on mode "* * *-O kodiak*" / ==== LEAVE MY BEAR BUDDY ALONE!!! ====;/mode $C +o kodiak
  371. /comment /on mode "* * *-O DreadLord*" / ==== DON'T MESS WITH DREADLORD!! *reops him* ====;/mode $C +o DreadLord
  372. /comment /on mode "* * *-O ce_nedra*" / ==== HEY!! LEAVE CE_NEDRA ALONE!! *reops* ====;/mode $C +o ce_nedra
  373. /comment /on mode "* * *-O snick*" / ==== HEY!! LEAVE SNICK ALONE!! *reops* ====;/mode $C +o snick
  374. /comment /on mode "* * *-O rags*" / ==== LEAVE RAGS ALONE!!! *reops him* ====;/mode $C +o rags
  375. /comment /on mode "* * *-O stale*" / ==== LEAVE STALE ALONE!! *reops* ====;/mode $C +o Stale
  376. /comment /on mode "* * *-O HotTubSrv*" / ==== LEAVE HOTTUBSRV ALONE!! ====;/mode $C +o HotTubSrv
  377. /comment /on mode "* * *-O Nap*" / ==== LEAVE NAP ALONE!! ====;/mode $C +o Nap
  378.  
  379. /comment ******** COMMANDS FOR BALOOBEAR / FIZZY *****************
  380.  
  381. /on msg "BalooBear op*" /mode $C +o $2
  382. /on msg "BalooBear deop*" /mode $C -o $2
  383. /on msg "BalooBear boot*" /kick $C $2
  384. /on msg "BalooBear later" /say ==== BYE ALL!!! ====;/exit LATER_ALL!
  385. /on msg "BalooBear serv*" /serv $2
  386. /on msg "BalooBear join*" /join $2
  387. /on msg "BalooBear leave*" /leave $2
  388. /on msg "BalooBear nick*" /nick $2
  389. /on msg "BalooBear ban*" /kick $C $2;/mode $C +b $2!*@*
  390.  
  391. /on msg "Fizzy op*" /mode $C +o $2
  392. /on msg "Fizzy deop*" /mode $C -o $2
  393. /on msg "Fizzy boot*" /kick $C $2
  394. /on msg "Fizzy later" /say ==== BYE ALL!!! ====;/exit LATER_ALL!
  395. /on msg "Fizzy serv*" /serv $2
  396. /on msg "Fizzy join*" /join $2
  397. /on msg "Fizzy leave*" /leave $2
  398. /on msg "Fizzy nick*" /nick $2
  399. /on msg "Fizzy ban*" /kick $C $2;/mode $C +b $2!*@*
  400.  
  401.  
  402. /comment ********************** THE END ************************
  403. /comment ****** BalooBot V3.7, a BalooBear production :) *******
  404.  
  405.  
  406.  
  407. '''---```---^^^^^^-----#-----~~~~~----'''------~~~~-----````~~~---------=\ /=
  408. .sig (n): a piece of mail with a fool at one  :  Ravi Narayan, CS, WPI   (0)
  409.           end and flames at the other. (C).   :  DoD #540 - SuzukiGS500E  H
  410.    o     _          _           _           _ :         _           _     H
  411.  _/\_> =| |========| |=========| |=========| |=========| |=========| |=======
  412. 0,> /0,=|w|,,=====,|,|.,===,,==| |,,===.,==|.|..======w| |..,,.====| |====,,=
  413.  
  414.  
  415.